package com.example.utils;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class HTTPUtils {

    /**
     * 发起一个 http 请求
     */
    @Async
    public void request() {
        int random = (int) (Math.random() * (1000 - 100 + 1)) + 100;
        System.out.println("发起请求: " + random);
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("请求结束: " + random);
    }
}
